<?php

$T->loadTpl("./html/" . $template . "/" . $qname . ".html");
$T->SetTpl('cssjs', 'html/cssjs.inc');
$T->SetTpl('jsmodel', 'html/jsmodel.inc');

$sname = isset($_GET['sname']) ? $_GET['sname'] : "";
$where = "";
if (!empty($sname)) {
    $where .= " and truename like '%" . $sname . "%' ";
    $T->Set("sname", $sname);
}
$type = isset($_GET['type']) ? $_GET['type'] : 0;
switch ($type) {
    case 1: //角色
        $T->SetBlock2("list", "select a.id as id,a.rolename as deptname from sys_role a left join sys_dict b on a.depttype=b.id left join sys_school c on a.mech=c.id order by id desc", array(array("block" => "rp", "pid" => "id", "sql" => "select username,truename from sys_member where role=? " . $where . " order by inserttime")));
        break;
    case 2: //用户组
        $T->SetBlock2("list", "select a.id as id,a.grpname as deptname from sys_custom_group a left join sys_school c on a.mech=c.id order by id desc", array(array("block" => "rp", "pid" => "id", "sql" => "select username,truename from sys_member where role=? " . $where . " order by inserttime")));
        break;

    default:    //部门
        $T->SetBlock2("list", "select a.id as id,a.deptname as deptname from sys_department a left join sys_dict b on a.depttype=b.id left join sys_school c on a.mech=c.id order by a.odx asc"
                , array(array("block" => "rp", "pid" => "id", "sql" => "select username,truename from sys_member where department=? " . $where . " order by inserttime")));

        break;
}
$T->Set("type", $type);
$T->Set("template",$template); 
$T->clearNaN();       
$T->clearNoN();
$T->display(); 
